/**
 * AI聊天相关类型定义
 */

/**
 * 消息发送者类型
 */
export enum MessageSender {
  USER = 'user',
  AI = 'ai'
}

/**
 * 聊天消息类型
 */
export interface ChatMessage {
  id: string;
  content: string;
  sender: MessageSender;
  timestamp: string;
}

/**
 * 对话类型
 */
export interface Conversation {
  id: string;
  title: string;
  messages: ChatMessage[];
  createdAt: string;
  updatedAt: string;
}

/**
 * 对话摘要类型（用于历史列表显示）
 */
export interface ConversationSummary {
  id: string;
  title: string;
  preview: string;
  createdAt: string;
  updatedAt: string;
}

/**
 * 时间分组类型
 */
export enum TimeGroup {
  TODAY = '今天',
  WEEK = '7 天内',
  MONTH = '30 天内',
  OLDER = '更早'
}

/**
 * 分组后的对话列表
 */
export interface GroupedConversations {
  [TimeGroup.TODAY]?: ConversationSummary[];
  [TimeGroup.WEEK]?: ConversationSummary[];
  [TimeGroup.MONTH]?: ConversationSummary[];
  [TimeGroup.OLDER]?: ConversationSummary[];
}

/**
 * 聊天上下文状态
 */
export interface AIChatState {
  conversations: Conversation[];
  currentConversationId: string | null;
  isOpen: boolean;
  isTyping: boolean;
  isSidebarOpen: boolean;
}

/**
 * 聊天上下文操作
 */
export interface AIChatContextType extends AIChatState {
  isLoading: boolean;
  getCurrentConversation: () => Conversation | null;
  getCurrentMessages: () => ChatMessage[];
  createNewConversation: () => Promise<void>;
  selectConversation: (conversationId: string) => void;
  deleteConversation: (conversationId: string) => Promise<void>;
  sendMessage: (content: string) => Promise<void>;
  toggleChat: () => void;
  toggleSidebar: () => void;
  getGroupedConversations: () => GroupedConversations;
  closeChat: () => void;
}
